home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / Xconq 7.0d37 / source / configure < prev    next >
Text File  |  1995-03-07  |  33KB  |  1,032 lines

  1. #!/bin/sh
  2.  
  3. ### WARNING: this file contains embedded tabs.  Do not run untabify on this file.
  4.  
  5. # Configuration script
  6. # Copyright (C) 1988, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
  7.  
  8. # This program is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 2 of the License, or
  11. # (at your option) any later version.
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU General Public License for more details.
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20. # Please report any problems running this configure script to
  21. # configure@cygnus.com
  22. # Please do not send reports about other problems to this address.  See
  23. # gdb/README, gas/README, etc., for info on where and how to report
  24. # problems about particular tools.
  25.  
  26. # This file was written by K. Richard Pixley.
  27.  
  28. #
  29. # Shell script to create proper links to machine-dependent files in
  30. # preparation for compilation.
  31. #
  32. # If configure succeeds, it leaves its status in config.status.
  33. # If configure fails after disturbing the status quo, 
  34. #       config.status is removed.
  35. #
  36.  
  37. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0 $argv; kill $$)
  38.  
  39. remove=rm
  40. hard_link=ln
  41. symbolic_link='ln -s'
  42.  
  43. #for Test
  44. #remove="echo rm"
  45. #hard_link="echo ln"
  46. #symbolic_link="echo ln -s"
  47.  
  48. # clear some things potentially inherited from environment.
  49.  
  50. Makefile=Makefile
  51. Makefile_in=Makefile.in
  52. arguments=$*
  53. build_alias=
  54. cache_file=
  55. cache_file_option=
  56. configdirs=
  57. exec_prefix=
  58. exec_prefixoption=
  59. fatal=
  60. floating_point=default
  61. gas=default
  62. host_alias=NOHOST
  63. host_makefile_frag=
  64. moveifchange=
  65. norecursion=
  66. other_options=
  67. package_makefile_frag=
  68. prefix=/usr/local
  69. progname=
  70. program_prefix=
  71. program_prefixoption=
  72. program_suffix=
  73. program_suffixoption=
  74. program_transform_name=
  75. program_transform_nameoption=
  76. redirect=">/dev/null"
  77. removing=
  78. site=
  79. site_makefile_frag=
  80. site_option=
  81. srcdir=
  82. srctrigger=
  83. subdirs=
  84. target_alias=NOTARGET
  85. target_makefile_frag=
  86. undefs=NOUNDEFS
  87. version="$Revision: 1.201 $"
  88. x11=default
  89.  
  90. ### we might need to use some other shell than /bin/sh for running subshells
  91. #
  92. config_shell=${CONFIG_SHELL-/bin/sh}
  93.  
  94. NO_EDIT="This file was generated automatically by configure.  Do not edit."
  95.  
  96. ## this is a little touchy and won't always work, but...
  97. ##
  98. ## if the argv[0] starts with a slash then it is an absolute name that can (and
  99. ## must) be used as is.
  100. ##
  101. ## otherwise, if argv[0] has no slash in it, we can assume that it is on the
  102. ## path.  Since PATH might include "." we also add `pwd` to the end of PATH.
  103. ##
  104.  
  105. progname=$0
  106. # if PWD already has a value, it is probably wrong.
  107. if [ -n "$PWD" ]; then PWD=`pwd`; fi
  108.  
  109. case "${progname}" in
  110. /*) ;;
  111. */*) ;;
  112. *)
  113.         PATH=$PATH:${PWD=`pwd`} ; export PATH
  114.         ;;
  115. esac
  116.  
  117. # Loop over all args
  118.  
  119. while :
  120. do
  121.  
  122. # Break out if there are no more args
  123.     case $# in
  124.     0)
  125.         break
  126.         ;;
  127.     esac
  128.  
  129. # Get the first arg, and shuffle
  130.     option=$1
  131.     shift
  132.  
  133. # Make all options have two hyphens
  134.     orig_option=$option    # Save original for error messages
  135.     case $option in
  136.     --*) ;;
  137.     -*) option=-$option ;;
  138.     esac
  139.         
  140. # Split out the argument for options that take them
  141.     case $option in
  142.     --*=*)
  143.         optarg=`echo $option | sed -e 's/^[^=]*=//'`
  144.         ;;
  145. # These options have mandatory values.  Since we didn't find an = sign,
  146. # the value must be in the next argument
  147.     --b* | --cache* | --ex* | --ho* | --pre* | --program-p* | --program-s* | --program-t* | --si* | --sr* | --ta* | --tm* | --x-*)
  148.         optarg=$1
  149.         shift
  150.         ;;
  151.     esac
  152.  
  153. # Now, process the options
  154.     case $option in
  155.  
  156.     --build* | --b*)
  157.         case "$build_alias" in
  158.         "") build_alias=$optarg ;;
  159.         *) echo '***' Can only configure for one build machine at a time.  1>&2
  160.            fatal=yes
  161.            ;;
  162.         esac
  163.         ;;
  164.     --cache*)
  165.         cache_file=$optarg
  166.         ;;
  167.     --disable-*)
  168.         enableopt=`echo ${option} | sed 's:^--disable-:enable_:;s:-:_:g'`
  169.         eval $enableopt=no
  170.         disableoptions="$disableoptions $option"
  171.         ;;
  172.     --enable-*)
  173.         case "$option" in
  174.         *=*)    ;;
  175.         *)    optarg=yes ;;
  176.         esac
  177.  
  178.         enableopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
  179.         eval $enableopt="$optarg"
  180.         enableoptions="$enableoptions $option"
  181.         ;;
  182.     --exec-prefix* | --ex*)
  183.         exec_prefix=$optarg
  184.         exec_prefixoption="--exec-prefix=$optarg"
  185.         ;;
  186.     --gas | --g*)
  187.         gas=yes
  188.         ;;
  189.     --help | --he*)
  190.         fatal=yes
  191.         ;;
  192.     --host* | --ho*)
  193.         case $host_alias in
  194.         NOHOST) host_alias=$optarg ;;
  195.         *) echo '***' Can only configure for one host at a time.  1>&2
  196.            fatal=yes
  197.            ;;
  198.         esac
  199.         ;;
  200.     --nfp | --nf*)
  201.         floating_point=no
  202.         ;;
  203.     --norecursion | --no*)
  204.         norecursion=yes
  205.         ;;
  206.     --prefix* | --pre*)
  207.         prefix=$optarg
  208.         prefixoption="--prefix=$optarg"
  209.         ;;
  210.     --program-prefix* | --program-p*)
  211.         program_prefix=$optarg
  212.         program_prefixoption="--program-prefix=$optarg"
  213.         ;;
  214.     --program-suffix* | --program-s*)
  215.         program_suffix=$optarg
  216.         program_suffixoption="--program-suffix=$optarg"
  217.         ;;
  218.     --program-transform-name* | --program-t*)
  219.         # Double any backslashes or dollar signs in the argument
  220.         program_transform_name="${program_transform_name} -e `echo ${optarg} | sed -e 's/\\\\/\\\\\\\\/g' -e 's/\\\$/$$/g'`"
  221.         program_transform_nameoption="${program_transform_nameoption} --program-transform-name='$optarg'"
  222.         ;;
  223.     --rm)
  224.         removing=--rm
  225.         ;;
  226.     --silent | --sil* | --quiet | --q*)
  227.         redirect=">/dev/null"
  228.         verbose=--silent
  229.         ;;
  230.     --site* | --sit*)
  231.         site=$optarg
  232.         site_option="--site=$optarg"
  233.         ;;
  234.     --srcdir*/ | --sr*/)
  235.                 # Remove trailing slashes.  Otherwise, when the file name gets
  236.                 # bolted into an object file as debug info, it has two slashes
  237.                 # in it.  Ordinarily this is ok, but emacs takes double slash
  238.                 # to mean "forget the first part".
  239.         srcdir=`echo $optarg | sed -e 's:/$::'`
  240.         ;;
  241.     --srcdir* | --sr*)
  242.         srcdir=$optarg
  243.         ;;
  244.     --target* | --ta*)
  245.         case $target_alias in
  246.         NOTARGET) target_alias=$optarg ;;
  247.         *) echo '***' Can only configure for one target at a time.  1>&2
  248.            fatal=yes
  249.            ;;
  250.         esac
  251.         ;;
  252.     --tmpdir* | --tm*)
  253.         TMPDIR=$optarg
  254.         tmpdiroption="--tmpdir=$optarg"
  255.         ;;
  256.     --verbose | --v | --verb*)
  257.         redirect=
  258.         verbose=--verbose
  259.         ;;
  260.     --version | --V | --vers*)
  261.         echo "This is Cygnus Configure version" `echo ${version} | sed 's/[ $:]//g'`
  262.         exit 0
  263.         ;;
  264.     --with-*)
  265.         case "$option" in
  266.         *=*)    ;;
  267.         *)    optarg=yes ;;
  268.         esac
  269.  
  270.         withopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
  271.         eval $withopt="$optarg"
  272.         withoptions="$withoptions $option"
  273.         ;;
  274.     --without-*)
  275.         withopt=`echo ${option} | sed 's:^--::;s:out::;s:-:_:g'`
  276.         eval $withopt=no
  277.         withoutoptions="$withoutoptions $option"
  278.         ;;
  279.     --x)    with_x=yes
  280.         withoptions="$withoptions --with-x"
  281.         ;;
  282.     --x-i* | --x-l*) other_options="$other_options $orig_option"
  283.         ;;
  284.     --*)
  285.         echo "configure: Unrecognized option: \"$orig_option\"; use --help for usage." >&2
  286.         exit 1
  287.         ;;
  288.     *)
  289.         case $undefs in
  290.         NOUNDEFS) undefs=$option ;;
  291.         *) echo '***' Can only configure for one host and one target at a time.  1>&2
  292.            fatal=yes
  293.            ;;
  294.         esac
  295.         ;;
  296.     esac
  297. done
  298.  
  299. # process host and target
  300.  
  301. # Do some error checking and defaulting for the host and target type.
  302. # The inputs are:
  303. #    configure --host=HOST --target=TARGET UNDEFS
  304. #
  305. # The rules are:
  306. # 1. You aren't allowed to specify --host, --target, and undefs at the
  307. #    same time.
  308. # 2. Host defaults to undefs.
  309. # 3. If undefs is not specified, then host defaults to the current host,
  310. #    as determined by config.guess.
  311. # 4. Target defaults to undefs.
  312. # 5. If undefs is not specified, then target defaults to host.
  313.  
  314. case "${fatal}" in
  315. "")
  316.     # Make sure that host, target & undefs aren't all specified at the
  317.     # same time.
  318.     case $host_alias---$target_alias---$undefs in
  319.     NOHOST---*---* | *---NOTARGET---* | *---*---NOUNDEFS)
  320.         ;;
  321.     *) echo '***' Can only configure for one host and one target at a time.  1>&2
  322.        fatal=yes
  323.        break 2
  324.         ;;
  325.     esac
  326.  
  327.     # Now, do defaulting for host.
  328.     case $host_alias in
  329.     NOHOST)
  330.         case $undefs in
  331.         NOUNDEFS)
  332.             # Neither --host option nor undefs were present.
  333.             # Call config.guess.
  334.             guesssys=`echo ${progname} | sed 's/configure$/config.guess/'`
  335.             if host_alias=`${guesssys}`
  336.             then
  337.                 # If the string we are going to use for
  338.                 # the target is a prefix of the string
  339.                 # we just guessed for the host, then
  340.                 # assume we are running native, and force
  341.                 # the same string for both target and host.
  342.                 case $target_alias in
  343.                 NOTARGET) ;;
  344.                 *)
  345.                     if expr $host_alias : $target_alias >/dev/null
  346.                     then
  347.                         host_alias=$target_alias
  348.                     fi
  349.                     ;;
  350.                 esac
  351.                 echo "Configuring for a ${host_alias} host." 1>&2
  352.                 arguments="--host=$host_alias $arguments"
  353.             else
  354.                 echo 'Config.guess failed to determine the host type.  You need to specify one.' 1>&2
  355.                 fatal=yes
  356.             fi
  357.             ;;
  358.         *)
  359.             host_alias=$undefs
  360.             ;;
  361.         esac
  362.     esac
  363.  
  364.     # Do defaulting for target.  If --target option isn't present, default
  365.     # to undefs.  If undefs isn't present, default to host.
  366.     case $target_alias in
  367.     NOTARGET)
  368.         case $undefs in
  369.         NOUNDEFS)
  370.             target_alias=$host_alias
  371.             ;;
  372.         *)
  373.             target_alias=$undefs
  374.             ;;
  375.         esac
  376.     esac
  377.     ;;
  378. *) ;;
  379. esac
  380.  
  381. if [ -n "${fatal}" -o "${host_alias}" = "help" ] ; then
  382.     exec 1>&2
  383.     echo Usage: configure [OPTIONS] [HOST]
  384.     echo
  385.     echo Options: [defaults in brackets]
  386.     echo ' --prefix=MYDIR         install into MYDIR [/usr/local]'
  387.     echo ' --exec-prefix=MYDIR     install host-dependent files into MYDIR [/usr/local]'
  388.     echo ' --help             print this message [normal config]'
  389.     echo ' --build=BUILD         configure for building on BUILD [BUILD=HOST]'
  390.     echo ' --host=HOST         configure for HOST [determined via config.guess]'
  391.     echo ' --norecursion         configure this directory only [recurse]'
  392.     echo ' --program-prefix=FOO     prepend FOO to installed program names [""]'
  393.     echo ' --program-suffix=FOO     append FOO to installed program names [""]'
  394.     echo ' --program-transform-name=P transform installed names by sed pattern P [""]'
  395.     echo ' --site=SITE         configure with site-specific makefile for SITE'
  396.     echo ' --srcdir=DIR         find the sources in DIR [. or ..]'
  397.     echo ' --target=TARGET     configure for TARGET [TARGET=HOST]'
  398.     echo ' --tmpdir=TMPDIR     create temporary files in TMPDIR [/tmp]'
  399.     echo ' --nfp             configure for software floating point [hard float]'
  400.     echo ' --with-FOO, --with-FOO=BAR package FOO is available (parameter BAR)'
  401.     echo ' --without-FOO         package FOO is NOT available'
  402.     echo ' --enable-FOO, --enable-FOO=BAR include feature FOO (parameter BAR)'
  403.     echo ' --disable-FOO         do not include feature FOO'
  404.     echo
  405.     echo 'Where HOST and TARGET are something like "sparc-sunos", "mips-sgi-irix5", etc.'
  406.     echo
  407.     if [ -r config.status ] ; then
  408.         cat config.status
  409.     fi
  410.  
  411.     exit 1
  412. fi
  413.  
  414. configsub=`echo ${progname} | sed 's/configure$/config.sub/'`
  415. moveifchange=`echo ${progname} | sed 's/configure$/move-if-change/'`
  416.  
  417. # this is a hack.  sun4 must always be a valid host alias or this will fail.
  418. if ${configsub} sun4 >/dev/null 2>&1 ; then
  419.         true
  420. else
  421.         echo '***' cannot find config.sub.  1>&2
  422.         exit 1
  423. fi
  424.  
  425. touch config.junk
  426. if ${moveifchange} config.junk config.trash ; then
  427.         true
  428. else
  429.         echo '***' cannot find move-if-change.  1>&2
  430.         exit 1
  431. fi
  432. rm -f config.junk config.trash
  433.  
  434. case "${srcdir}" in
  435. "")
  436.         if [ -r configure.in ] ; then
  437.                 srcdir=.
  438.         else
  439.                 if [ -r ${progname}.in ] ; then
  440.                         srcdir=`echo ${progname} | sed 's:/configure$::'`
  441.                 else
  442.                         echo '***' "Can't find configure.in.  Try using --srcdir=some_dir"  1>&2
  443.                         exit 1
  444.                 fi
  445.         fi
  446.         ;;
  447. *) ;;
  448. esac
  449.  
  450. ### warn about some conflicting configurations.
  451.  
  452. case "${srcdir}" in
  453. ".") ;;
  454. *)
  455.         if [ -f ${srcdir}/config.status ] ; then
  456.                 echo '***' Cannot configure here in \"${PWD=`pwd`}\" when \"${srcdir}\" is currently configured. 1>&2
  457.                 exit 1
  458.         fi
  459. esac
  460.  
  461. # default exec_prefix
  462. case "${exec_prefixoption}" in
  463. "") exec_prefix="\$(prefix)" ;;
  464. *) ;;
  465. esac
  466.  
  467. ### break up ${srcdir}/configure.in.
  468. case "`grep '^# per\-host:' ${srcdir}/configure.in`" in
  469. "")
  470.         echo '***' ${srcdir}/configure.in has no \"per-host:\" line. 1>&2
  471.         exit 1
  472.         ;;
  473. *) ;;
  474. esac
  475.  
  476. case "`grep '^# per\-target:' ${srcdir}/configure.in`" in
  477. "")
  478.         echo '***' ${srcdir}/configure.in has no \"per-target:\" line. 1>&2
  479.         exit 1
  480.         ;;
  481. *) ;;
  482. esac
  483.  
  484. case "${TMPDIR}" in
  485. "") TMPDIR=/tmp ; export TMPDIR ;;
  486. *) ;;
  487. esac
  488.  
  489. # keep this filename short for &%*%$*# 14 char file names
  490. tmpfile=${TMPDIR}/cONf$$
  491. # Note that under many versions of sh a trap handler for 0 will *override* any
  492. # exit status you explicitly specify!  At this point, the only non-error exit
  493. # is at the end of the script; these actions are duplicated there, minus
  494. # the "exit 1".  Don't use "exit 0" anywhere after this without resetting the
  495. # trap handler, or you'll lose.
  496. trap "rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos; exit 1" 0 1 2 15
  497.  
  498. # split ${srcdir}/configure.in into common, per-host, per-target,
  499. # and post-target parts.  Post-target is optional.
  500. sed -e '/^# per\-host:/,$d' ${srcdir}/configure.in > ${tmpfile}.com
  501. sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.hst
  502. if grep '^# post-target:' ${srcdir}/configure.in >/dev/null ; then
  503.   sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.tgt
  504.   sed -e '1,/^# post\-target:/d' ${srcdir}/configure.in > ${tmpfile}.pos
  505. else
  506.   sed -e '1,/^# per\-target:/d' ${srcdir}/configure.in > ${tmpfile}.tgt
  507.   echo >${tmpfile}.pos
  508. fi
  509.  
  510. ### do common part of configure.in
  511.  
  512. . ${tmpfile}.com
  513.  
  514. # some sanity checks on configure.in
  515. case "${srctrigger}" in
  516. "")
  517.         echo '***' srctrigger not set in ${PWD=`pwd`}/configure.in.  1>&2
  518.         exit 1
  519.         ;;
  520. *) ;;
  521. esac
  522.  
  523. case "${build_alias}" in
  524. "")    ;;
  525. *)
  526.     if result=`${config_shell} ${configsub} ${build_alias}` ; then
  527.         buildopt="--build=${build_alias}"
  528.         build_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
  529.         build_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
  530.         build_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
  531.         build=${build_cpu}-${build_vendor}-${build_os}
  532.     else
  533.         echo "Unrecognized build system name ${build_alias}." 1>&2
  534.         exit 1
  535.     fi
  536.     ;;
  537. esac
  538.  
  539. if result=`${config_shell} ${configsub} ${host_alias}` ; then
  540.     true
  541. else
  542.     echo "Unrecognized host system name ${host_alias}." 1>&2
  543.     exit 1
  544. fi
  545. host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
  546. host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
  547. host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
  548. host=${host_cpu}-${host_vendor}-${host_os}
  549.  
  550. . ${tmpfile}.hst
  551.  
  552. if result=`${config_shell} ${configsub} ${target_alias}` ; then
  553.     true
  554. else
  555.     echo "Unrecognized target system name ${target_alias}." 1>&2
  556.     exit 1
  557. fi
  558. target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
  559. target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
  560. target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
  561. target=${target_cpu}-${target_vendor}-${target_os}
  562.  
  563. . ${tmpfile}.tgt
  564.  
  565. # Find the source files, if location was not specified.
  566. case "${srcdir}" in
  567. "")
  568.         srcdirdefaulted=1
  569.         srcdir=.
  570.         if [ ! -r ${srctrigger} ] ; then
  571.                 srcdir=..
  572.         fi
  573.         ;;
  574. *) ;;
  575. esac
  576.  
  577. if [ ! -r ${srcdir}/${srctrigger} ] ; then
  578.         case "${srcdirdefaulted}" in
  579.         "") echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/${srcdir}" 1>&2 ;;
  580.         *)  echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/. or ${PWD=`pwd`}/.." 1>&2 ;;
  581.         esac
  582.  
  583.         echo '***' \(At least ${srctrigger} is missing.\) 1>&2
  584.         exit 1
  585. fi
  586.  
  587. # Some systems (e.g., one of the i386-aix systems the gas testers are
  588. # using) don't handle "\$" correctly, so don't use it here.
  589. tooldir='$(exec_prefix)'/${target_alias}
  590.  
  591. if [ "${host_alias}" != "${target_alias}" ] ; then
  592.     if [ "${program_prefixoption}" = "" ] ; then
  593.         if [ "${program_suffixoption}" = "" ] ; then 
  594.             if [ "${program_transform_nameoption}" = "" ] ; then
  595.                 program_prefix=${target_alias}- ;
  596.             fi
  597.         fi
  598.     fi
  599. fi
  600.  
  601. # Merge program_prefix and program_suffix onto program_transform_name.
  602. # (program_suffix used to use $, but it's hard to preserve $ through both
  603. # make and sh.)
  604. if [ "${program_suffix}" != "" ] ; then
  605.     program_transform_name="-e s,\\\\(.*\\\\),\\\\1${program_suffix}, ${program_transform_name}"
  606. fi
  607.  
  608. if [ "${program_prefix}" != "" ] ; then
  609.     program_transform_name="-e s,^,${program_prefix}, ${program_transform_name}"
  610. fi
  611.  
  612. for subdir in . ${subdirs} ; do
  613.  
  614.     # ${subdir} is relative path from . to the directory we're currently
  615.     # configuring.
  616.     # ${invsubdir} is inverse of ${subdir), *with* trailing /, if needed.
  617.     invsubdir=`echo ${subdir}/ | sed -e 's|\./||g' -e 's|[^/]*/|../|g'`
  618.  
  619.     ### figure out what to do with srcdir
  620.     case "${srcdir}" in
  621.         ".")  # no -srcdir option.  We're building in place.
  622.                 makesrcdir=. ;;
  623.         /*) # absolute path
  624.                 makesrcdir=`echo ${srcdir}/${subdir} | sed -e 's|/\.$||'`
  625.                 ;;
  626.         *) # otherwise relative
  627.                 case "${subdir}" in
  628.                 .) makesrcdir=${srcdir} ;;
  629.                 *) makesrcdir=${invsubdir}${srcdir}/${subdir} ;;
  630.                 esac
  631.                 ;;
  632.     esac
  633.  
  634.     if [ "${subdir}/" != "./" ] ; then
  635.         Makefile=${subdir}/Makefile
  636.     fi
  637.  
  638.     if [ ! -d ${subdir} ] ; then
  639.         if mkdir ${subdir} ; then
  640.                 true
  641.         else
  642.                 echo '***' "${progname}: could not make ${PWD=`pwd`}/${subdir}" 1>&2
  643.                 exit 1
  644.         fi
  645.     fi
  646.  
  647.     case "${removing}" in
  648.     "")
  649.         case "${subdir}" in
  650.         .) ;;
  651.         *) eval echo Building in ${subdir} ${redirect} ;;
  652.         esac
  653.  
  654.         # FIXME Should this be done recursively ??? (Useful for e.g. gdbtest)
  655.         # Set up the list of links to be made.
  656.         # ${links} is the list of link names, and ${files} is the list of names to link to.
  657.  
  658.         # Make the links.
  659.         configlinks="${links}"
  660.         if [ -r ${subdir}/config.status ] ; then
  661.                 mv -f ${subdir}/config.status ${subdir}/config.back
  662.         fi
  663.         while [ -n "${files}" ] ; do
  664.                 # set file to car of files, files to cdr of files
  665.                 set ${files}; file=$1; shift; files=$*
  666.                 set ${links}; link=$1; shift; links=$*
  667.  
  668.                 if [ ! -r ${srcdir}/${file} ] ; then
  669.                         echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
  670.                         echo '***' "since the file \"${srcdir}/${file}\" does not exist." 1>&2
  671.                         exit 1
  672.                 fi
  673.  
  674.                 ${remove} -f ${link}
  675.         # Make a symlink if possible, otherwise try a hard link
  676.         if ${symbolic_link} ${srcdir}/${file} ${link} >/dev/null 2>&1 ; then
  677.             true
  678.         else
  679.             # We need to re-remove the file because Lynx leaves a 
  680.             # very strange directory there when it fails an NFS symlink.
  681.             ${remove} -r -f ${link}
  682.             ${hard_link} ${srcdir}/${file} ${link}
  683.         fi
  684.                 if [ ! -r ${link} ] ; then
  685.                         echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
  686.                         exit 1
  687.                 fi
  688.  
  689.                 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
  690.         done
  691.  
  692.         # Create a .gdbinit file which runs the one in srcdir
  693.         # and tells GDB to look there for source files.
  694.  
  695.         if [ -r ${srcdir}/${subdir}/.gdbinit ] ; then
  696.                 case ${srcdir} in
  697.                 .) ;;
  698.                 *) cat > ${subdir}/.gdbinit <<EOF
  699. # ${NO_EDIT}
  700. dir ${makesrcdir}
  701. dir .
  702. source ${makesrcdir}/.gdbinit
  703. EOF
  704.                         ;;
  705.                 esac
  706.         fi
  707.  
  708.         # Install a makefile, and make it set VPATH
  709.         # if necessary so that the sources are found.
  710.         # Also change its value of srcdir.
  711.         # NOTE: Makefile generation constitutes the majority of the time in configure.  Hence, this section has
  712.         # been somewhat optimized and is perhaps a bit twisty.
  713.  
  714.         # code is order so as to try to sed the smallest input files we know.
  715.  
  716.         # the four makefile fragments MUST end up in the resulting Makefile in this order: 
  717.         # package, target, host, and site.  so do these separately because I don't trust the
  718.         #  order of sed -e expressions.
  719.  
  720.         if [ -f ${srcdir}/${subdir}/${Makefile_in} ] ; then
  721.  
  722.             # Conditionalize for this site from "Makefile.in" (or whatever it's called) into Makefile.tem
  723.             rm -f ${subdir}/Makefile.tem
  724.               case "${site}" in
  725.               "") cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem ;;
  726.               *)
  727.                       site_makefile_frag=${srcdir}/config/ms-${site}
  728.  
  729.                       if [ -f ${site_makefile_frag} ] ; then
  730.                               sed -e "/^####/  r ${site_makefile_frag}" ${srcdir}/${subdir}/${Makefile_in} \
  731.                                       > ${subdir}/Makefile.tem
  732.                       else
  733.                               cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem
  734.                               site_makefile_frag=
  735.                       fi
  736.                       ;;
  737.             esac
  738.             # working copy now in ${subdir}/Makefile.tem
  739.  
  740.             # Conditionalize the makefile for this host.
  741.             rm -f ${Makefile}
  742.             case "${host_makefile_frag}" in
  743.               "") mv ${subdir}/Makefile.tem ${Makefile} ;;
  744.               *)
  745.                       if [ ! -f ${host_makefile_frag} ] ; then
  746.                               host_makefile_frag=${srcdir}/${host_makefile_frag}
  747.                       fi
  748.                       if [ -f ${host_makefile_frag} ] ; then
  749.                               sed -e "/^####/  r ${host_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
  750.                       else
  751.                               echo '***' Expected host makefile fragment \"${host_makefile_frag}\" 1>&2
  752.                               echo '***' is missing in ${PWD=`pwd`}. 1>&2
  753.                               mv ${subdir}/Makefile.tem ${Makefile}
  754.                       fi
  755.             esac
  756.             # working copy now in ${Makefile}
  757.  
  758.             # Conditionalize the makefile for this target.
  759.             rm -f ${subdir}/Makefile.tem
  760.             case "${target_makefile_frag}" in
  761.               "") mv ${Makefile} ${subdir}/Makefile.tem ;;
  762.               *)
  763.                       if [ ! -f ${target_makefile_frag} ] ; then
  764.                               target_makefile_frag=${srcdir}/${target_makefile_frag}
  765.                       fi
  766.                       if [ -f ${target_makefile_frag} ] ; then
  767.                               sed -e "/^####/  r ${target_makefile_frag}" ${Makefile} > ${subdir}/Makefile.tem
  768.                       else
  769.                               mv ${Makefile} ${subdir}/Makefile.tem
  770.                               target_makefile_frag=
  771.                       fi
  772.                       ;;
  773.             esac
  774.             # real copy now in ${subdir}/Makefile.tem
  775.  
  776.             # Conditionalize the makefile for this package.
  777.             rm -f ${Makefile}
  778.             case "${package_makefile_frag}" in
  779.               "") mv ${subdir}/Makefile.tem ${Makefile} ;;
  780.               *)
  781.                       if [ ! -f ${package_makefile_frag} ] ; then
  782.                               package_makefile_frag=${srcdir}/${package_makefile_frag}
  783.                       fi
  784.                       if [ -f ${package_makefile_frag} ] ; then
  785.                               sed -e "/^####/  r ${package_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
  786.                   rm -f ${subdir}/Makefile.tem
  787.                       else
  788.                               echo '***' Expected package makefile fragment \"${package_makefile_frag}\" 1>&2
  789.                               echo '***' is missing in ${PWD=`pwd`}. 1>&2
  790.                               mv ${subdir}/Makefile.tem ${Makefile}
  791.                       fi
  792.             esac
  793.             # working copy now in ${Makefile}
  794.  
  795.             mv ${Makefile} ${subdir}/Makefile.tem
  796.  
  797.             # real copy now in ${subdir}/Makefile.tem
  798.  
  799.             # prepend warning about editting, and a bunch of variables.
  800.             rm -f ${Makefile}
  801.             cat > ${Makefile} <<EOF
  802. # ${NO_EDIT}
  803. VPATH = ${makesrcdir}
  804. links = ${configlinks}
  805. host_alias = ${host_alias}
  806. host_cpu = ${host_cpu}
  807. host_vendor = ${host_vendor}
  808. host_os = ${host_os}
  809. host_canonical = ${host_cpu}-${host_vendor}-${host_os}
  810. target_alias = ${target_alias}
  811. target_cpu = ${target_cpu}
  812. target_vendor = ${target_vendor}
  813. target_os = ${target_os}
  814. target_canonical = ${target_cpu}-${target_vendor}-${target_os}
  815. EOF
  816.         case "${build}" in
  817.           "") ;;
  818.           *)  cat >> ${Makefile} << EOF
  819. build_alias = ${build_alias}
  820. build_cpu = ${build_cpu}
  821. build_vendor = ${build_vendor}
  822. build_os = ${build_os}
  823. build_canonical = ${build_cpu}-${build_vendor}-${build_os}
  824. EOF
  825.         esac
  826.  
  827.             case "${package_makefile_frag}" in
  828.               "") ;;
  829.               /*) echo package_makefile_frag = ${package_makefile_frag} >>${Makefile} ;;
  830.               *)  echo package_makefile_frag = ${invsubdir}${package_makefile_frag} >>${Makefile} ;;
  831.             esac
  832.  
  833.             case "${target_makefile_frag}" in
  834.               "") ;;
  835.               /*) echo target_makefile_frag = ${target_makefile_frag} >>${Makefile} ;;
  836.               *)  echo target_makefile_frag = ${invsubdir}${target_makefile_frag} >>${Makefile} ;;
  837.             esac
  838.  
  839.             case "${host_makefile_frag}" in
  840.               "") ;;
  841.               /*) echo host_makefile_frag = ${host_makefile_frag} >>${Makefile} ;;
  842.               *)  echo host_makefile_frag = ${invsubdir}${host_makefile_frag} >>${Makefile} ;;
  843.             esac
  844.  
  845.             if [ "${site_makefile_frag}" != "" ] ; then
  846.                 echo site_makefile_frag = ${invsubdir}${site_makefile_frag} >>${Makefile}
  847.             fi 
  848.  
  849.         # make sure that some sort of reasonable default exists for these 
  850.         # two variables
  851.         CXX=${CXX-"g++ -O"}
  852.         CC=${CC-cc}
  853.  
  854.             # reset prefix, exec_prefix, srcdir, SUBDIRS, NONSUBDIRS,
  855.             # remove any form feeds.
  856.             if [ -z "${subdirs}" ]; then
  857.                 rm -f ${subdir}/Makefile.tem2
  858.                 sed -e "s:^SUBDIRS[     ]*=.*$:SUBDIRS = ${configdirs}:" \
  859.                     -e "s:^NONSUBDIRS[     ]*=.*$:NONSUBDIRS = ${noconfigdirs}:" \
  860.                     ${subdir}/Makefile.tem > ${subdir}/Makefile.tem2
  861.                 rm -f ${subdir}/Makefile.tem
  862.                 mv ${subdir}/Makefile.tem2 ${subdir}/Makefile.tem
  863.             fi
  864.             sed -e "s:^prefix[     ]*=.*$:prefix = ${prefix}:" \
  865.                     -e "s:^exec_prefix[     ]*=.*$:exec_prefix = ${exec_prefix}:" \
  866.             -e "s:^SHELL[     ]*=.*$:SHELL = ${config_shell}:" \
  867.                     -e "s:^srcdir[     ]*=.*$:srcdir = ${makesrcdir}:" \
  868.                     -e "s/ //" \
  869.                     -e "s:^program_prefix[     ]*=.*$:program_prefix = ${program_prefix}:" \
  870.                     -e "s:^program_suffix[     ]*=.*$:program_suffix = ${program_suffix}:" \
  871.                     -e "s:^program_transform_name[     ]*=.*$:program_transform_name = ${program_transform_name}:" \
  872.                     -e "s:^tooldir[     ]*=.*$:tooldir = ${tooldir}:" \
  873.                     ${subdir}/Makefile.tem >> ${Makefile}
  874.             # final copy now in ${Makefile}
  875.  
  876.         else
  877.            echo "No Makefile.in found in ${srcdir}/${subdir}, unable to configure" 1>&2
  878.         fi
  879.  
  880.         rm -f ${subdir}/Makefile.tem
  881.  
  882.         case "${host_makefile_frag}" in
  883.         "") using= ;;
  884.         *) using="and \"${host_makefile_frag}\"" ;;
  885.         esac
  886.  
  887.         case "${target_makefile_frag}" in
  888.         "") ;;
  889.         *) using="${using} and \"${target_makefile_frag}\"" ;;
  890.         esac
  891.  
  892.         case "${site_makefile_frag}" in
  893.         "") ;;
  894.         *) using="${using} and \"${site_makefile_frag}\"" ;;
  895.         esac
  896.  
  897.         newusing=`echo "${using}" | sed 's/and/using/'`
  898.         using=${newusing}
  899.         echo "Created \"${Makefile}\" in" ${PWD=`pwd`} ${using}
  900.  
  901.         . ${tmpfile}.pos
  902.  
  903.         # describe the chosen configuration in config.status.
  904.         # Make that file a shellscript which will reestablish
  905.         # the same configuration.  Used in Makefiles to rebuild
  906.         # Makefiles.
  907.  
  908.         case "${norecursion}" in
  909.         "") arguments="${arguments} --norecursion" ;;
  910.         *) ;;
  911.         esac
  912.  
  913.         if [ ${subdir} = . ] ; then
  914.             echo "#!/bin/sh
  915. # ${NO_EDIT}
  916. # This directory was configured as follows:
  917. ${progname}" ${arguments}  "
  918. # ${using}" > ${subdir}/config.new
  919.         else
  920.             echo "#!/bin/sh
  921. # ${NO_EDIT}
  922. # This directory was configured as follows:
  923. cd ${invsubdir}
  924. ${progname}" ${arguments}  "
  925. # ${using}" > ${subdir}/config.new
  926.         fi
  927.         chmod a+x ${subdir}/config.new
  928.         if [ -r ${subdir}/config.back ] ; then
  929.                 mv -f ${subdir}/config.back ${subdir}/config.status
  930.         fi
  931.         ${moveifchange} ${subdir}/config.new ${subdir}/config.status
  932.         ;;
  933.  
  934.     *)  rm -f ${Makefile} ${subdir}/config.status ${links} ;;
  935.     esac
  936. done
  937.  
  938. # If there are subdirectories, then recur. 
  939. if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then 
  940.         for configdir in ${configdirs} ; do
  941.  
  942.                 if [ -d ${srcdir}/${configdir} ] ; then
  943.                         eval echo Configuring ${configdir}... ${redirect}
  944.                         case "${srcdir}" in
  945.                         ".") ;;
  946.                         *)
  947.                                 if [ ! -d ./${configdir} ] ; then
  948.                                         if mkdir ./${configdir} ; then
  949.                                                 true
  950.                                         else
  951.                                                 echo '***' "${progname}: could not make ${PWD=`pwd`}/${configdir}" 1>&2
  952.                                                 exit 1
  953.                                         fi
  954.                                 fi
  955.                                 ;;
  956.                         esac
  957.  
  958.                         POPDIR=${PWD=`pwd`}
  959.                         cd ${configdir} 
  960.  
  961. ### figure out what to do with srcdir
  962.                         case "${srcdir}" in
  963.                         ".") newsrcdir=${srcdir} ;; # no -srcdir option.  We're building in place.
  964.                         /*) # absolute path
  965.                                 newsrcdir=${srcdir}/${configdir}
  966.                                 srcdiroption="--srcdir=${newsrcdir}"
  967.                                 ;;
  968.                         *) # otherwise relative
  969.                                 newsrcdir=../${srcdir}/${configdir}
  970.                                 srcdiroption="--srcdir=${newsrcdir}"
  971.                                 ;;
  972.                         esac
  973.  
  974.             # Handle --cache-file=../XXX
  975.             case "${cache_file}" in
  976.             "") # empty
  977.                 ;;
  978.             /*) # absolute path
  979.                 cache_file_option="--cache-file=${cache_file}"
  980.                 ;;
  981.             *) # relative path
  982.                 cache_file_option="--cache-file=../${cache_file}"
  983.                 ;;
  984.             esac
  985.  
  986. ### check for guested configure, otherwise fix possibly relative progname
  987.                         if [ -f ${newsrcdir}/configure ] ; then
  988.                                 recprog=${newsrcdir}/configure
  989.                         elif [ -f ${newsrcdir}/configure.in ] ; then
  990.                                 case "${progname}" in
  991.                                 /*)     recprog=${progname} ;;
  992.                                 *)      recprog=../${progname} ;;
  993.                                 esac
  994.             else
  995.                 eval echo No configuration information in ${configdir} ${redirect}
  996.                 recprog=
  997.                         fi
  998.  
  999. ### The recursion line is here.
  1000.             if [ ! -z "${recprog}" ] ; then
  1001.                             if eval ${config_shell} ${recprog} ${verbose} ${buildopt} --host=${host_alias} --target=${target_alias} \
  1002.                                     ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
  1003.                                     ${srcdiroption} ${program_prefixoption} ${program_suffixoption} ${program_transform_nameoption} ${site_option} ${withoptions} ${withoutoptions} ${enableoptions} ${disableoptions} ${cache_file_option} ${removing} ${other_options} ${redirect} ; then
  1004.                                     true
  1005.                             else
  1006.                     echo Configure in `pwd` failed, exiting. 1>&2
  1007.                                     exit 1
  1008.                             fi
  1009.             fi
  1010.  
  1011.                         cd ${POPDIR}
  1012.                 fi
  1013.         done
  1014. fi
  1015.  
  1016. # Perform the same cleanup as the trap handler, minus the "exit 1" of course,
  1017. # and reset the trap handler.
  1018. rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos
  1019. trap 0
  1020.  
  1021. exit 0
  1022.  
  1023. #
  1024. # Local Variables:
  1025. # fill-column: 131
  1026. # End:
  1027. #
  1028.  
  1029. # end of configure
  1030.